package com.drinking.springcloudconsumer.controller;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class HelloController {

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/")
    public String hello(){
        return "欢迎访问消费者服务器主页。";
    }

    @RequestMapping("/test")
    public String test(){
        ResponseEntity<String> response = restTemplate.getForEntity("http://SPRINGCLOUD-PROVIDER/test",String.class);
//        System.out.println(response.getStatusCode());
//        System.out.println(response.getHeaders());

//        restTemplate.postForObject();


        return response.getBody();
    }

}
